import time
import functools

def log_decorator(func):
    @functools.wraps(func)
    def wrapper(*args,**kwargs):
        start_time=time.time()
        print(f"函数{func.__name__}开始执行")
        try:
            result=func(*args,**kwargs)
            return result
        except Exception as e:
            print(f"函数{func.__name__}执行出错:{e}")
        finally:
            end_time=time.time()
            duration=end_time-start_time
            print(f"函数{func.__name__}执行耗时{duration:.3f}秒")
    return wrapper
@log_decorator
def divide(a,b):
    return a/b
divide(10,2)
# divide(10,0)
